<?php

namespace App\Model\Device;

use App\Model\BaseModel;

class DeviceLogModel extends BaseModel
{

	public $tableName = "sc_device_log";

	/**
	 * 通过条件获取数据库里面的设备
	 * @auth   xiaozhi
	 * @param  array   $condition [description]
	 * @return [type]             [description]
	 */
	public function getLogData($field = '*', $where = [],  $page = 1, $pageSize =10, $order = ['A.id', 'desc'])
    {
		$this->withTotalCount()
		    ->field($field)
		    ->order($order[0], $order[1])
		    ->alias('A')
			->join('mymk_device as B','A.deviceid=B.deviceremark','LEFT')
			->where($where)
            ->page($page, $pageSize)
            ->all();
		

		$count = $this->lastQueryResult()->getTotalCount();
        $lists = $this->lastQueryResult()->getResult();

        return ['count' => $count, 'lists' => $lists];
	}

}